package com.heima.common.util;

/**
 * @Author Administrator
 * @Date 2023/3/6
 **/
public class UserInfoThreadLocal {

    private static ThreadLocal<LoginUserInfo> tl = new ThreadLocal<>();

    /**
     * 向ThreadLocal对象存值
     * @param loginUserInfo
     */
    public static void set(LoginUserInfo loginUserInfo){
        if (loginUserInfo!=null){
            tl.set(loginUserInfo);
        }
    }

    /**
     * 从ThreadLocal中取值
     * @return
     */
    public static LoginUserInfo get(){
        return tl.get();
    }

    /**
     * 清理ThreadLocal中的数据
     */
    public static void remove(){
        tl.remove();
    }
}
